import { RouteRecordRaw } from "vue-router";
import NoAuthView from "@/views/NoAuthView.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestion from "@/views/question/AddQuestion.vue";
import ManageQuestion from "@/views/question/ManageQuestion.vue";
import UpdateQuestion from "@/views/question/UpdateQuestion.vue";
import QuestionList from "@/views/question/QuestionList.vue";
import QuestionView from "@/views/question/QuestionView.vue";
import QuestionSubmitList from "@/views/question/QuestionSubmitList.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "题目列表",
    component: QuestionList,
  },
  {
    path: "/question/submitList",
    name: "题目提交列表",
    component: QuestionSubmitList,
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestion,
    meta: {
      access: ACCESS_ENUM.LOGIN,
    },
  },
  {
    path: "/manage/question",
    name: "管理题目",
    component: ManageQuestion,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/do/question/:id",
    name: "做题",
    component: QuestionView,
    meta: {
      showInMenu: false,
    },
  },
  {
    path: "/update/question",
    name: "修改题目",
    component: UpdateQuestion,
    meta: {
      showInMenu: false,
    },
  },
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    meta: {
      showInMenu: false,
    },
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      showInMenu: false,
    },
  },
  {
    path: "/about",
    name: "个人中心",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
    meta: {
      access: ACCESS_ENUM.USER,
      showInMenu: false,
    },
  },
];
